package util
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;
	
	public class Arrow extends Sprite
	{
		private var _target:Point;
		private var _vx:Number = 30;
		private var _vy:Number = -30;
		private var gravity:Number = 2;
		private var friction:Number = .1;
		
		public function Arrow()
		{
			draw();
		}
		
		public function draw():void {
			graphics.lineStyle(1,0x0,.7);
			graphics.beginFill(0x0,.5);
			graphics.moveTo(0,-5);
			graphics.lineTo(10,-5);
			graphics.lineTo(10,-10);
			graphics.lineTo(20,0);
			graphics.lineTo(10,10);
			graphics.lineTo(10,5);
			graphics.lineTo(0,5);
			graphics.endFill();
		}
		
		public function set target(t:Point):void {
			this._target = t;
		}
		
		public function fly():void {
			this.addEventListener(Event.ENTER_FRAME,onEnterFrame);
		}
		
		public function onEnterFrame(event:Event):void {
			this._vx -= friction;
			this._vy += gravity;
			
			if(this._vx>0)
			this.x += this._vx;
			this.y += this._vy;
		}
	}
}